10 DEFINT A-Z:KEY OFF:RANDOMIZE TIMER
20 DIM SX(100),SY(100),EX(100),EY(100):IL=16
30 VGA=1:ON ERROR GOTO 300:SCREEN 12:ON ERROR GOTO 0
40 IF VGA=1 THEN COLOR 0:SW=639:SH=479:CL=15 ELSE SCREEN 1:COLOR 0,1:SW=319:SH=199:CL=3
50 CLS:P=0:L=IL:D=1:FOR I=0 TO IL:SX(I)=0:SY(I)=0:EX(I)=0:EY(I)=0:NEXT I
60 SX(0)=INT(RND*SW/2):SY(0)=INT(RND*SH/2)
70 EX(0)=INT(RND*SW/2)+SW/2:EY(0)=INT(RND*SH/2)+SH/2
80 SX(IL)=SX(0):SY(IL)=SY(0):EX(IL)=EX(0):EY(IL)=EY(0)
90 MSX=1:MSY=1:MEX=1:MEY=1:T0#=TIMER:TC#=T0#
100 WHILE INKEY$="":C=INT(RND*CL)+1
110 LINE (SX(D),SY(D))-(EX(D),EY(D)),0
120 LINE (SX(P),SY(P))-(EX(P),EY(P)),C
130 P=P+1:IF P>IL THEN P=0
140 D=D+1:IF D>IL THEN D=0
150 L=L+1:IF L>IL THEN L=0
160 SX(P)=SX(L)+MSX:IF SX(P)<0 THEN SX(P)=-SX(P):MSX=-MSX ELSE IF SX(P)>SW THEN SX(P)=SW*2-SX(P):MSX=-MSX
170 SY(P)=SY(L)+MSY:IF SY(P)<0 THEN SY(P)=-SY(P):MSY=-MSY ELSE IF SY(P)>SH THEN SY(P)=SH*2-SY(P):MSY=-MSY
180 EX(P)=EX(L)+MEX:IF EX(P)<0 THEN EX(P)=-EX(P):MEX=-MEX ELSE IF EX(P)>SW THEN EX(P)=SW*2-EX(P):MEX=-MEX
190 EY(P)=EY(L)+MEY:IF EY(P)<0 THEN EY(P)=-EY(P):MEY=-MEY ELSE IF EY(P)>SH THEN EY(P)=SH*2-EY(P):MEY=-MEY
200 MSX=MSX+INT(RND*5)-2:IF MSX<-5 THEN MSX=-5 ELSE IF MSX>5 THEN MSX=5
210 MSY=MSY+INT(RND*5)-2:IF MSY<-5 THEN MSY=-5 ELSE IF MSY>5 THEN MSY=5
220 MEX=MEX+INT(RND*5)-2:IF MEX<-5 THEN MEX=-5 ELSE IF MEX>5 THEN MEX=5
230 MEY=MEY+INT(RND*5)-2:IF MEY<-5 THEN MEY=-5 ELSE IF MEY>5 THEN MEY=5
240 T#=TIMER:WHILE (T#-T0#)<0.016:T#=TIMER:WEND:T0#=T#
250 IF VGA=0 AND T#-TC#>1 THEN TC#=T#:COLOR ,(INT(RND*100) AND 1)
260 WEND
270 CLS:SCREEN 0:WIDTH 80:CLS:END
300 IF ERR=5 THEN VGA=0:RESUME NEXT ELSE ON ERROR GOTO 0

